package com.game.thrones.constant;

/**
 * 0成功 1-100 系统错误 101-200 用户
 * 
 * @author naida
 *
 */
public enum Errors {
	USER_NOT_EXIST(101, "用户不存在"), PASSWORD_ERROR(102, "密码错误"), SYSTEM_REQUEST_PARAM_ERROR(103, "参数格式错误"),

	USER_TOKEN_ERROR(104, "用户token失效"), USER_WXOPENID_ERROR(105, "用户wxopenid获取不到用户信息"),

	NOT_WEIXIN_ERROR(106, "请使用微信客户端登录"), DR_HOUSE_EN_NAME_REPEAT(201, "项目名称重复"),

	VER_CODE_FAIL(202, "验证码错误"), DICTIONARY_NAME_REPEAT(203, "选项名称重复"), NO_MEMBERCARD(204,
			
	"会员卡不存在"), NO_PACKAGEINFO(215, "套餐不存在"),

	NO_AVAILABLECREDIT(205, "可用额度不足"),CUSTOMER_SIGNED(206, "客户已签到无法删除"),ACTIVITY_START(207, "活动已开始无法删除"), 
	
	ACTIVITY_CUSTOMER(208, "活动已有预约用户无法删除"),  DICTIONARY_ABNAME_REPEAT(209, "别名重复"),PACKAGE_EXIST(210, "已存在主套餐，只能绑定一个主套餐"),
	
	AVA_NOT_FULL(211, "卡内余额不足无法购买套餐"),FULL_OF_AVA(212, "退费金额超过卡内余额"),Y_SIDER(213, "该会员已经预约"),OUT_SERVICE_COUNT(214, "该会员已经预约"),
	
	DISHES_Y(216, "菜品已存在"),LOOP_N(217, "找不到客户入住信息"),
	
	TRANSFER_ENCODING_NOT_EXIST(3, "没权限或业务不存在"), FORM_VALID(2,"表单验证错误"), SYSTEM_ERROR(1, "系统错误"), SUCCESS(0,

	"操作成功"), LACK_CONTENT(4, "缺少上下文环境"), NOT_LOGIN(5, "用户未登录"), NO_ENDEMIC(6, "未选择地方中心"),OLDPASSWORD_ERROR(7, "原密码错误"),NOT_FOUND_USER(8, "找不到该用户"),

	USERNAME_REPEAT(401, "用户名重复"), COMPANY_EXIST(402, "该公司已经被注册"), DATA_REPEAT(403, "数据重复"),

	DATA_NOTEXIST(404, "数据不存在"), DATA_VALID_ERROR(405, "数据校验错误"), NOT_PERMISSION(406, "没有权限"), ROLE_NAME_REPEAT(

	407, "权限名重复"), DATA_EXIST(408, "关联数据存在无法删除"),DATA_ROLE_REPEAT(409, "系统角色重复"),DATA_HEAD_REPEAT(410, "总部节点已存在"),
	MEMBER_DATA_NOTEXIST(411, "初始会员卡数据不存在"),CUSTOMER_ROOM_USE(412, "存在客户入住信息，无法删除"),CUSTOMER_EXTEND(413, "客户扩展信息已存在"),
	VERCODE_EMPTY(1006, "验证码为空"),

	VERCODE_ERROR(1007, "验证码错误"), SAVE_ERROR(1, "保存失败"), MODIFY_ERROR(2, "修改失败"),

	DELETE_ERROR(3, "删除失败"), DOWN_ERROR(99, "下载失败"), DOWN_IO_ERROR(-99, "关闭下载输出流失败"), VALID_ERROR(9999, "数据验证错误"),

	CUSTOMERCOMP_NO_DATA(4, "投诉信息不存在"),CUSTOMERCOMP_NO_REPEAT(5, "投诉信息状态错误"),DISHESLIBRARY_ROOT_DATA(410, "菜品库根节点不存在"),
	DISHES_USED(207, "菜品已使用无法删除"),;

	public int code;
	public String label;

	private Errors(int code, String label) {
		this.code = code;
		this.label = label;
	}

	/**
	 *
	 * @param code
	 *            状态
	 * @return 描述
	 */
	public static String getLabel(int code) {
		String result = "";
		for (Errors status : Errors.values()) {
			if (status.code == code) {
				result = status.label;
			}
		}
		return result;
	}

	public static Errors getErrors(int code) {
		for (Errors errors : Errors.values()) {
			if (code == errors.code) {
				return errors;
			}
		}

		return null;
	}
}
